﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using PositionUtils;

namespace Tanks
{
    class IFire : IFieldObject
    {
        protected float speed = 0;
        protected Vector2[] boards = new Vector2[4];

        public IFire(Game1 game, Vector2 position, float rotation)
            : base(game, new PropertiesObject(), Resources.ProjectileT34)
        {
            Properties.IsFon = false;
            this.rotation = rotation;
            this.position = position;
            Properties.IsShoot = true;
            Properties.WasActive = true;
            Properties.Damage = 100;
            Properties.StartPosition = position;
        }

        public override void Update(GameTime gameTime)
        {
            position.X += -(float)(speed * Math.Cos(rotation));
            if (position.X > game.width + this.texture.Width / 2 || position.X < 0 - this.texture.Width / 2)
                game.DeleteObject(this);
            position.Y += -(float)(speed * Math.Sin(rotation));
            if (position.Y > game.heigth + this.texture.Width / 2 || position.Y < 0 - this.texture.Width / 2)
                game.DeleteObject(this);
            boards = PositionUtils.mPositionUtils.computeBoards(position, rotation, this.texture.Height, this.texture.Width);
        }

        public override void Draw()
        {
            game.SpriteBatch.Draw(texture, position, null, Color.White, rotation,
                    new Vector2(texture.Width / 2, texture.Height / 2), 1.0f, SpriteEffects.None, 0);
        }
        public override Vector2 getActualPosition()
        {
            return position;
        }
        public override float getActualRotation()
        {
            return rotation;
        }
        public override void collisionNotFounded()
        {
            
        }
        public override void collisionRotNotFounded()
        {
            
        }
        public override Vector2[] getBoards()
        {
            return boards;
        }
        public override Vector2[] getActualBoards()
        {
            return mPositionUtils.computeBoards(position, rotation, texture.Height, texture.Width);
        }
        public override void collisionFounded(IFieldObject two)
        {
            game.DeleteObject(this);
            game.AddObject(new Animation(Resources.Alcaida, game, new Vector2(this.position.X ,this.position.Y), this.rotation, 30, 1.0f));
        }
        
    }
}
